shadow: add a method to paint the shadow for a PangoLayout
authorCosimo Cecchi <cosimoc@gnome.org>
Fri, 20 May 2011 20:05:57 +0000 (16:05 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Fri, 20 May 2011 22:49:54 +0000 (18:49 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=649314

gtk/gtkshadow.c
gtk/gtkshadowprivate.h

index 1825a87fe4d827ef92770ffe9a9c67bdea4f6a90..89702c0a3f3ce719eb9c7ba1701f2e2d77abe9f2 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "gtkshadowprivate.h"
 #include "gtkstylecontext.h"
+#include "gtkpango.h"
 
 typedef struct _GtkShadowElement GtkShadowElement;
 
@@ -253,3 +254,31 @@ _gtk_shadow_to_string (GtkShadow *shadow)
 
   return g_string_free (str, FALSE);
 }
+
+void
+_gtk_text_shadow_paint_layout (GtkShadow       *shadow,
+                               cairo_t         *cr,
+                               gdouble          x,
+                               gdouble          y,
+                               PangoLayout     *layout)
+{
+  GList *l;
+  GtkShadowElement *element;
+
+  /* render shadows starting from the last one,
+   * and the others on top.
+   */
+  for (l = g_list_last (shadow->elements); l != NULL; l = l->prev)
+    {
+      element = l->data;
+
+      cairo_save (cr);
+
+      cairo_move_to (cr, x + element->hoffset, y + element->voffset);
+      gdk_cairo_set_source_rgba (cr, &element->color);
+      _gtk_pango_fill_layout (cr, layout);
+
+      cairo_restore (cr);
+  }
+}
+
index f82391177501c18ea3ee931c0a65b98255ab383d..846b1d30fafaa85e780f908b8f3881c4cbd652b1 100644 (file)
@@ -25,6 +25,7 @@
 #include <glib-object.h>
 #include <gtk/gtkstyleproperties.h>
 #include <gtk/gtksymboliccolor.h>
+#include <gtk/gtkicontheme.h>
 
 G_BEGIN_DECLS
 
@@ -52,6 +53,12 @@ GtkShadow *_gtk_shadow_resolve        (GtkShadow          *shadow,
                                        GtkStyleProperties *props);
 gboolean   _gtk_shadow_get_resolved   (GtkShadow          *shadow);
 
+void       _gtk_text_shadow_paint_layout (GtkShadow       *shadow,
+                                          cairo_t         *cr,
+                                          gdouble          x,
+                                          gdouble          y,
+                                          PangoLayout     *layout);
+
 G_END_DECLS
 
 #endif /* __GTK_SHADOW_H__ */